﻿@{
    ViewBag.Title = "";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<link href="/Content/plugin/bootstrap.datepicker/css/bootstrap-datetimepicker.min.css" rel="stylesheet" />
<form id="form" class="form-horizontal m" role="form">
    <div class="form-group">
        <label class="col-sm-2 control-label">任务组名称<span class="text-red"> *</span></label>
        <div class="col-xs-12 col-sm-4">
            <input id="jobGroupName" name="JobGroupName" col="JobGroupName" type="text" class="form-control required " placeholder="请输入任务组名称" />
        </div>
        <label class="col-sm-2 control-label ">任务名称<span class="text-red"> *</span></label>
        <div class="col-xs-12 col-sm-4">
            <input id="jobName" name="JobName" col="JobName" type="text" class="form-control required " placeholder="请输入任务名称" />
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label ">程序集<span class="text-red"> *</span></label>
        <div class="col-xs-12 col-sm-4">
            <input id="dllName" name="DllName" col="DllName" type="text" class="form-control required " placeholder="请输入程序集" />
        </div>
        <label class="col-sm-2 control-label ">类名<span class="text-red"> *</span></label>
        <div class="col-xs-12 col-sm-4">
            <input id="className" name="ClassName" col="ClassName" type="text" class="form-control required " placeholder="请输入类名" />
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label ">方法名<span class="text-red"> *</span></label>
        <div class="col-xs-12 col-sm-4">
            <input id="functionName" name="FunctionName" col="FunctionName" type="text" class="form-control required " placeholder="请输入方法名" />
        </div>
        <label class="col-sm-2 control-label ">Cron表达式<span class="text-red"> *</span></label>
        <div class="col-xs-12 col-sm-4">
            <input id="cronExpression" name="CronExpression" col="CronExpression" type="text" class="form-control required " placeholder="请输入Cron表达式" />
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label ">开始时间<span class="text-red"> *</span></label>
        <div class="col-xs-12 col-sm-4">
            <div class='input-group date' id='jobStartTime'>
                <input type='text' class="form-control required" placeholder="开始时间" col="StartTime" name="StartTime" />
                <span class="input-group-addon">
                    <span class="glyphicon glyphicon-calendar"></span>
                </span>
            </div>
        </div>
        <label class="col-sm-2 control-label ">结束时间<span class="text-red"> *</span></label>
        <div class="col-xs-12 col-sm-4">
            <div class='input-group date' id='jobEndTime'>
                <input type='text' class="form-control required" placeholder="结束时间" col="EndTime" name="EndTime" />
                <span class="input-group-addon">
                    <span class="glyphicon glyphicon-calendar"></span>
                </span>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label ">备注说明<span class="text-red"> *</span></label>
        <div class="col-sm-10">
            <textarea id="remark" name="Remark" col="Remark" type="text" class="form-control required " rows="5" placeholder="请输入备注说明" ></textarea>
        </div>
    </div>
</form>
<script src="/Content/plugin/bootstrap.datepicker/js/moment-with-locales.js"></script>
<script src="/Content/plugin/bootstrap.datepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript">
    var id = frame.request("id");
    $(function () {
        $("#jobStartTime").datetimepicker({
            format: 'YYYY-MM-DD 00:00:00',
            showClear: true,
            locale: moment.locale('zh-cn')
        });
        $("#jobEndTime").datetimepicker({
            format: 'YYYY-MM-DD HH:mm:ss',
            showClear: true,
            locale: moment.locale('zh-cn')
        });
        getForm();
    });

    function getForm() {
        if (!!id) {
            frame.ajax({
                url: '@Url.Content("/Manage/AutoJob/SetForm")' + '?id=' + id,
                type: 'get',
                success: function (obj) {
                    if (obj.success) {
                        $('#form').setWebControls(obj.data);
                    }
                }
            });
        }
        else {
            var defaultData = {};
            defaultData.EndTime = "9999-12-31 00:00:00";
            $('#form').setWebControls(defaultData);
        }
    }

    function saveForm(index) {
        if ($('#form').validate().form()) {
            var postData = $('#form').getWebControls({ Id: id });
            frame.ajax({
                url: '@Url.Content("/Manage/AutoJob/SaveForm")',
                type: 'post',
                data: postData,
                success: function (obj) {
                    if (obj.success) {
                        frame.msgSuccess(obj.message);
                        parent.searchGrid();
                        parent.layer.close(index);
                    }
                    else {
                        frame.msgError(obj.message);
                    }
                }
            });
        }
    }
</script>